Experienced / Expert level questions & answers
Ques 1. The code in a finally clause will never fail to execute, right?
Using System.exit(1); in try block will not allow finally code to execute.
Ques 2. What mechanisms are used by a Servlet Container to maintain session information?
Cookies, URL rewriting, and HTTPS protocol information are used to maintain session information
Ques 3. Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?
Yes, but Before calling the destroy() method, the servlet container waits for the remaining threads that are executing the servlet?s service() method to finish.
Ques 4. Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?
Since ServletRequest has the current request path to evaluae the relative path while ServletContext does not.
Ques 5. What is the difference between an application server and a Web server?
Most helpful rated by users:
- What is Servlet?
- Why is Servlet so popular?
- What is servlet container?
- When a client request is sent to the servlet container, how does the container choose which servlet to invoke?
- If a servlet is not properly initialized, what exception may be thrown?